package lab2p2;

/**
 * <p>Title: AirplaneCosting</p>
 * <p>Description: CS 235 Lab #2</p>
 *         Example of how not using encapsulation can result in bugs.
 * @author Anthony Varghese, inspired by an example program in Head First C#.
 * @date   August 8th 2013
 * @team   
 */

public class AirplaneCosting {
	/**
	 * Static final data members
	 * A final data member is a "constant" - i.e. not variable.
	 * Making a final data member public will not cause problems
	 *  because the values in final members cannot be changed.   
	 * Since all instances of this class will see the same value
	 *  for a final data member, we can make it static as well. 
	 */
	public static final float cost_of_regular_plane = 1000000;
	public static final float cost_of_luxury_plane  = 1750000;

	/**
	 * Instance data members
	 */
	private int number_of_planes;
	public boolean luxury;
	private float total_cost;

	/**
	 * Default constructor
	 */
	public AirplaneCosting(){
		number_of_planes = 0;
		luxury = false;
		total_cost = 0;
	}
	
	/**
	 * setNumber - sets the number of planes
	 */
	public void setNumber( int n ){
		number_of_planes = n;
		if (luxury)
			total_cost = number_of_planes * cost_of_luxury_plane;
		else
			total_cost = number_of_planes * cost_of_regular_plane;
	}

	/**
	 * getCost - computes and returns total cost
	 */
	public float getCost(){
		return total_cost;
	}
}